package com.palm.core.nami;

import org.noear.nami.NamiException;

import java.util.Arrays;

public class NamiInvokeException extends NamiException {
    private int code;
    private byte[] respBody;
    private String bodyStr;
    public NamiInvokeException(int code,byte[] respBody,String message) {
        super(message);
        this.code=code;
        this.respBody=respBody;
    }
    public int getCode() {
        return code;
    }

    public byte[] getRespBody() {
        return respBody;
    }

    public String getBodyStr() {
        if (bodyStr == null) {
            bodyStr = new String(respBody);
            //清掉body
            respBody = null;
        }
        return bodyStr;
    }

    @Override
    public String toString() {
        String s = getClass().getName();
        return s+":"+code+" - "+getBodyStr();
    }
}
